﻿#set($PKColumnName="")
#foreach($u in $TableInfos)
#beforeall
#each
#foreach($c in $u.ColumnInfos)  
#beforeall
#each 
#if($c.IsPK=="True")
#set($PKColumnName=  $c.ColumnName)
#end
#end
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BrainSoft.Web.Manager.SystemMain.${u.TabName}.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>${u.TabCaption}</title>
<link href="../../css/reset.css" rel="stylesheet" type="text/css" />
<link href="../../css/zh-cn-system.css" rel="stylesheet" type="text/css" />
<link href="../../css/table_form.css" rel="stylesheet" type="text/css" />
<link href="../../js/Pagination/pagination.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" href="../../css/style/zh-cn-styles1.css" title="styles1" media="screen" />
	<link rel="alternate stylesheet" type="text/css" href="../../css/style/zh-cn-styles2.css" title="styles2" media="screen" />
	<link rel="alternate stylesheet" type="text/css" href="../../css/style/zh-cn-styles3.css" title="styles3" media="screen" />
    <link rel="alternate stylesheet" type="text/css" href="../../css/style/zh-cn-styles4.css" title="styles4" media="screen" />

<script language="javascript" type="text/javascript" src="../../js/admin_common.js"></script>
<script language="javascript" type="text/javascript" src="../../js/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="../../js/styleswitch.js"></script>
<script language="javascript" type="text/javascript" src="../../js/jquery-jtemplates.js"></script>
<script language="javascript" type="text/javascript" src="../../js/Pagination/jquery.pagination.js"></script>
<script type="text/javascript">
    var pagesize = BrainSoft.PageSize;
    var page = 1;
    var pageCount = 0;
    var optInit = null;
    $(document).ready(function () {
        ajaxList(page);
    });
    function ajaxAutoList() {
        ajaxList(page);
    }
    function ajaxList(currentpage) {
        if (currentpage != null) page = currentpage;
        jQuery.ajax({
            type: "get",
            dataType: "json",
            data: "start=" + currentpage + "&limit=" + pagesize + "&time=" + (new Date().getTime()),
            url: "Default.aspx?CMD=List",
            error: function (XmlHttpRequest, textStatus, errorThrown) { alert(XmlHttpRequest.responseText); },
            success: function (d) {
                if (d) {
                    if (optInit == null || (pageCount != d.totalPorperty)) {
                        optInit = getOptionsFromForm();
                        $("#Pagination").pagination(d.totalPorperty, optInit);
                        pageCount = d.totalPorperty;
                    }
                }
                $("#divList").setTemplateElement("Template-List");
                $("#divList").processTemplate(d);
            }
        });
    }

    //分页控件回调
    function pageselectCallback(page_index, jq) {
        page = page_index + 1;
        ajaxList(page);
        return true;
    }

    //分页控件配置
    function getOptionsFromForm() {
        var opt = { callback: pageselectCallback };
        // Collect options from the text fields - the fields are named like their option counterparts
        opt["items_per_page"] = pagesize;
        opt["num_display_entries"] = 10;
        opt["num_edge_entries"] = 1;
        opt["prev_text"] = "上一页";
        opt["next_text"] = "下一页";

        // Avoid html injections in this demo
        var htmlspecialchars = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" }
        jQuery.each(htmlspecialchars, function (k, v) {
            opt.prev_text = opt.prev_text.replace(k, v);
            opt.next_text = opt.next_text.replace(k, v);
        })
        return opt;
    }

    function ajaxDelete(name) {
        var str = "";
        $("[name='" + name + "']").each(function () {
            if (this.checked == true) {
                if (str == "") {
                    str = $(this).val()
                }
                else {
                    str = str + "_" + $(this).val()
                }
            }
        })
        if (!confirm("您确定要删除" + str + "吗？")) {
            return;
        }
        if (str == "") {
            alert("请选择要删除的列");
            return;
        }
        jQuery.ajax({
            type: "get",
            dataType: "json",
            data: "time=" + (new Date().getTime()),
            url: "Default.aspx?CMD=Delete&DId=" + str,
            error: function (XmlHttpRequest, textStatus, errorThrown) { alert("error" + XmlHttpRequest.responseText); },
            success: function (d) {
                if (d.success == "true") {
                    ajaxList(page);
                }
                else {
                    if (d.message) {
                        alert(d.message);
                    }
                    else {
                        alert("删除失败");
                    }
                }
            }
        });
    }
    function formEdit(id) {
        window.top.art.dialog({ id: 'edit', iframe: 'SystemMain/${u.TabName}/Manager.aspx?CMD=Edit&EId=' + id, title: '编辑${u.TabCaption}', width: '700', height: '400', lock: true }, function () { var d = window.top.art.dialog({ id: 'edit' }).data.iframe; var form = d.document.getElementById('dosubmit'); form.click(); return false; }, function () { window.top.art.dialog({ id: 'edit' }).close() }); void (0);
    }
</script>
<style type="text/css">
.bcEED {
    background: #EED;
}
.bcDEE {
    background: #DEE;
}
</style>
</head>
<body>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
    <a class="add fb" href="javascript:window.top.art.dialog({id:'add',iframe:'SystemMain/${u.TabName}/Manager.aspx?CMD=New', title:'添加会员', width:'800', height:'400', lock:true}, function(){var d = window.top.art.dialog({id:'add'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'add'}).close()});void(0);"><em>添加${u.TabCaption}</em></a>　    </div>
</div>
<style type="text/css">
	html{_overflow-y:scroll}
</style>
<div class="pad-lr-10">
<form name="myform"  method="post" onsubmit="checkuid();return false;">
<div class="table-list">
<div id="divList">
</div>
<div class="btn">
<label for="check_box">全选/取消</label> <input  type="button" class="button" name="dosubmit" value="删除" onclick="ajaxDelete('DId');" />
<input type="button" class="button" name="dosubmit" onclick="ajaxList(page);" value="刷新"/>
</div>
<div id="pages"></div>
</div>
</form>
</div>
<!-- Templates -->
  <p style="display:none"><textarea id="Template-List" rows="0" cols="0"><!--
    {!template MAIN}
      <table width="100%" cellspacing="0" >
	<thead>
		<tr>
        <th  align="left" width="20"><input type="checkbox" value="" id="check_box" onclick="selectall('DId');"></th>
#foreach($c in $u.ColumnInfos)  
#beforeall
#each 
#if($c.TypeName!="ntext")
               <th align="left">${c.DeText}</th>
#end   
#end  
            <th align="left">操作</th>
		</tr>
	</thead>
<tbody>
   {!foreach _____root as Cust}
          {!include ROW root=_____Cust}
        {!/for}
</tbody>
</table>
    {!/template MAIN}
    {!template ROW}
       <tr>
		<td align="left"><input type="checkbox" value="{_____${PKColumnName}}" name="DId"></td>
        #foreach($c in $u.ColumnInfos)  
#beforeall
#each 
#if(${c.TypeName}=="bit" || $c.TypeName=="tinyint")
        <td align="left">
            {!if _____${c.ColumnName} == "1"}
			<font >是</font>
            {!elseif _____${c.ColumnName} == "0"}
			<font >否</font>
            {!else}
            <font >其他</font>
			{!/if}
        </td>
#elseif($c.TypeName=="ntext")

#else
                <td align="left">{_____${c.ColumnName}}</td>
#end   
#end     
		<td align="left">
			<a href="javascript:formEdit({_____${PKColumnName}})">[修改]</a>
		</td>
    </tr>
    {!/template ROW}
  --></textarea></p>
  <!-- Output elements -->
</body>
</html>
#end
<!--
{!=={#
$T.==_____
-->
